import request from "@/utils/request.js";
import { useTokenStore } from "@/stores/token";

// 定义获取文章列表的方法
export const articleCategoryListService = () => {
  //   const tokenStore = useTokenStore();
  //   return request.get("/category", {
  //     headers: { Authorization: tokenStore.token },
  //   });
  return request.get("/category");
};

//定义文章分类添加的方法
export const articleCategoryAddService = (categoryData) => {
  return request.post("/category", categoryData);
};

//定义文章分类修改的方法
export const articleCategoryUpdateService = (categoryData) => {
  return request.put("/category", categoryData);
};

// 定义文章分类删除的方法
export const articleCategoryDeleteService = (id) => {
  return request.delete("/category?id=" + id);
};

// 定义文章列表查询的方法
export const articleListService = (params) => {
  return request.get("/article", { params: params });
};

// 定义添加文章的方法
export const articleAddService = (articleData) => {
  return request.post("/article", articleData);
};

// 定义修改文章的方法
export const articleUpdateService = (articleData) => {
  return request.put("/article", articleData);
};

// 定义删除文章的方法
export const articleDeleteService = (id) => {
  return request.delete("/article?id=" + id);
};
